package cn.com.ustudy.course.core.model.entity;

import cn.com.ustudy.course.core.model.enums.CourseType;
import cn.melonlib.cores.commons.model.entity.TenantRecordEntity;
import cn.melonlib.cores.model.anno.ModelComment;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.Type;

import javax.persistence.*;

@SuppressWarnings("serial")
@Data
@EqualsAndHashCode(callSuper=true)
@Entity(name = "Course")
@Table(name = "crs_course")
@ModelComment("课程")
public class Course extends TenantRecordEntity {
	
	@ManyToOne(cascade={CascadeType.REFRESH},fetch=FetchType.LAZY)
	@JoinColumn(name="cc_id")
	@ModelComment(value = "课程分类",required = true)
	private CourseCatalog courseCatalog;

	@ModelComment("课程分类名称")
    private String courseCatalogName;
	
	@ModelComment(value = "课程标签")
	private String tags;
	
    @ModelComment(value = "课程名称",required = true)
	private String name;
	
    @ModelComment("封面图")
	private String logo;
	
    @ModelComment("讲师")
	private String teacherName;
	
	@ModelComment("学分")
	private Double credit;
	
	
	@Column
	@Lob
	@Type(type = "org.hibernate.type.TextType")
	@ModelComment("课程课件，章节树信息")
	private String sections;

	@ModelComment("开放学习")
	private Boolean pub = true;
	
	@ModelComment("总时长")
	private Long totalTime = 0L;
	
	@ModelComment("点击量")
	private Long clickNum = 0L;	
	
	@ModelComment("上线")
	private Boolean online = true;

	@ModelComment("课程类型")
	@Enumerated(EnumType.STRING)
	private CourseType courseType=CourseType.ONLINE;

	@Column
	@Lob
	@Type(type = "org.hibernate.type.TextType")
	@Basic(fetch=FetchType.LAZY)
	@ModelComment("课程介绍")
	private String memo;

}
